package ckw.database;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class VotingSubcardOption extends core.modules.database.SuperVotingSubcardOption
		implements Serializable {

	private static final long serialVersionUID = -3987898493902911377L;

	private VotingSubcard votingSubcard;
	private Set<Vote> votes = new HashSet<Vote>();

	public VotingSubcardOption() {
		super();
	}

	public VotingSubcardOption(String name, VotingSubcard votingSubcard) {
		super(name);
		addToVotingSubcard(votingSubcard);
	}

	public VotingSubcard getVotingSubcard() {
		return votingSubcard;
	}

	public void setVotingSubcard(VotingSubcard votingSubcard) {
		this.votingSubcard = votingSubcard;
	}
	
	public void addToVotingSubcard(VotingSubcard votingSubcard){
		setVotingSubcard(votingSubcard);
		votingSubcard.getVotingSubcardOptions().add(this);
	}
	
	public void removeFromVotingSubcard(VotingSubcard votingSubcard){
		setVotingSubcard(null);
		votingSubcard.getVotingSubcardOptions().remove(this);
	}

	public Set<Vote> getVotes() {
		return votes;
	}

	public void setVotes(Set<Vote> votes) {
		this.votes = votes;
	}
	
	public void addToVote(Vote vote){
		this.getVotes().add(vote);
		vote.getVotingSubcardOptions().add(this);
	}
	
	public void removeFromVote(Vote vote){
		this.getVotes().remove(vote);
		vote.getVotingSubcardOptions().remove(this);
	}
}
